# -*- coding: utf-8 -*-

# Convert 数据转换

from morsecoder.constant import *

def option_convert(option: dict, is_encode: bool) -> dict:
    result = {
        'sep': '/',
        'long': '-',
        'short': '.',
    }

    if is_encode:
        result.pop('sep')

    for key in result:
        if key in option:
            result[key] = option[key]

    return result

def encode_convert(char, *, long, short) -> str:
    return char \
         .replace('1', long) \
         .replace('0', short)

def decode_convert(char, *, long, short) -> str:
    return char \
            .replace(long, '1') \
            .replace(short, '0')
